// TCPServer.cpp : Defines the entry point for the console application.
//

#include "TCPServer.h"
#include "dbmsl.h"

using namespace std;

int startServer()
{
	WSADATA wsaData; // WinSock library info
	char cmd[10];

	if (WSAStartup(MAKEWORD(1,0), &wsaData) != 0) {
		std::cout << "Can't load WinSock" << endl;
		return -1;
	}

//	std::cout << "WinSock started" << endl;

	HANDLE hServThread; // handler for ServerThread
	DWORD dwServThreadId; // server thread identifier

	// Create thread for port service (server)
	hServThread = CreateThread(NULL, 0, ServerThread, 0, 0, &dwServThreadId);
	if (hServThread == NULL) {
		std::cout << "Can't create server thread" << endl;
		return -1;
	}

	// Wait for user's action
//	std::cout << "Command" << endl;
	while(strcmp(cmd, "exit") != 0) {
		std::cin >> cmd;
//		std::cout << endl;
	}

	return 0;
}